//
// Created by QU on 2023/8/16.
//

#ifndef VHDLSENDER_HEADER_H
#define VHDLSENDER_HEADER_H

#include <stdint.h>

//#define TEST_MODE

//#define DEBUG_PRINT_PARAMETER_CONTENT

//#define DEBUG_PRINT_HEADER_CONTENT
//#define DEBUG_PRINT_BUFFER_CONTENT

//#define DEBUG_PRINT_OUTBUFFER_CONTENT       // 总开关
//#define DEBUG_PRINT_OUTBUFFER_HEADER_CONTENT    // 受控于DEBUG_PRINT_OUTBUFFER_CONTENT
//#define DEBUG_PRINT_OUTBUFFER_BODY_CONTENT    // 受控于DEBUG_PRINT_OUTBUFFER_CONTENT

// 定义调试信息打印宏
#define DEBUG_PRINT_ERROR_MESSAGE
#define DEBUG_PRINT_WARNING_MESSAGE
#define DEBUG_PRINT_DEBUG_MESSAGE
#define DEBUG_PRINT_INFO_MESSAGE

enum VC_TYPE {
    VC_4 = 4,
    VC_12 = 12
};

enum GENERATE_DATA_TYPE {
    FIXED_60A1DA8E = 0,
    FIXED_LowerINC_HigherLOID = 1,
    FIXED_LogicINC = 2,
    FIXED_00TOFF = 3,
    INPUTFILE,

};

// vcTypeHeader_t定义
typedef struct {
    uint16_t logicalChannelID;
    uint16_t physicalChannelID;
    uint16_t SQ;
    uint16_t frameLength;
    uint16_t frameNum;
    uint16_t vc_type;
} __attribute__((packed)) vcTypeHeader_t;

// VC-4结构定义
// LOAD
typedef struct {
    uint8_t load[2340];
} __attribute__((packed)) vc4FrameLoad_t;

// BODY
typedef struct {
    uint16_t MFI;
    vc4FrameLoad_t LOAD;
} __attribute__((packed)) vc4FrameBody_t;

typedef struct {
    vcTypeHeader_t HEADER;
    vc4FrameBody_t BODY;
} __attribute__((packed)) vc4FrameFull_t;

// VC-12结构定义
typedef struct {
    uint8_t load[136];
} __attribute__((packed)) vc12FrameLoad_t;

typedef struct {
    uint16_t MFI;
    vc12FrameLoad_t LOAD;
} __attribute__((packed)) vc12FrameBody_t;

typedef struct {
    vcTypeHeader_t HEADER;
    vc12FrameBody_t BODY;
} __attribute__((packed)) vc12FrameFull_t;


// 定义了一些常量.
const static size_t VC_FRAME_HEADER_LENGTH = sizeof(vcTypeHeader_t);

const static size_t VC4_FRAME_FULL_LENGTH = sizeof(vc4FrameFull_t); // 单个VC-4帧结构,包含开销
const static size_t VC4_FRAME_BODY_LENGTH = sizeof(vc4FrameBody_t);
const static size_t VC4_FRAME_LOAD_LENGTH = sizeof(vc4FrameLoad_t);

const static size_t VC12_FRAME_FULL_LENGTH = sizeof(vc12FrameFull_t); // 单个VC-12帧结构,包含开销
const static size_t VC12_FRAME_BODY_LENGTH = sizeof(vc12FrameBody_t);
const static size_t VC12_FRAME_LOAD_LENGTH = sizeof(vc12FrameLoad_t);

#endif //VHDLSENDER_HEADER_H
